function BXToolbarSet(e,t,o){this.className="BXToolbarSet";e.unselectable="on";this.pWnd=e;this.pMainObj=t;this.bVertical=o;this.pWnd.className="bxedtoolbarset";this.arToolbarPositions=[];e.style.display="";e.parentNode.style.display="";if(o){e.style.verticalAlign="top";this.pWnd=e.appendChild(BX.create("TABLE",{props:{unselectable:"on",cellSpacing:0,cellPadding:0,border:0}}));this.pWnd.insertRow(0);this.pParent=e}}BXToolbarSet.prototype={HitTest:function(e,t,o){var i=3,l,s,n;if(!(s=CACHE_DISPATCHER["BXToolbarSet_pos_"+o]))s=CACHE_DISPATCHER["BXToolbarSet_pos_"+o]=BX.pos(this.bVertical?this.pParent:this.pWnd);if(s["left"]-i<e&&e<s["right"]+i&&s["top"]-i<t&&t<s["bottom"]+i){l={row:0,col:0,addrow:false};if(this.bVertical)n=this.pWnd.rows[0].cells;else n=this.pWnd.childNodes;if(!n||n.length<=0){l["addrow"]=true;return l}var r,a,d,p=n.length,h;for(d=0;d<p;d++){h=BX.pos(n[d]);if(this.bVertical){if(h["left"]-i<e&&e<h["right"]+i){if(h["left"]+i>e){l["addrow"]=true;l["col"]=d}else if(h["right"]-i<e){l["addrow"]=true;l["col"]=d+1}else{l["col"]=d;r=n[d].childNodes[0].rows;for(a=r.length-1;a>0;a--){var c=r[a].cells[0];var b=BX.pos(c);if(b["top"]-i<t){l["row"]=a;break}}}return l}}else{if(h["top"]-i<t&&t<h["bottom"]+i){if(h["top"]+i>t){l["addrow"]=true;l["row"]=d}else if(h["bottom"]-i<t){l["addrow"]=true;l["row"]=d+1}else{l["row"]=d;r=n[d].rows[0].cells;for(a=r.length-1;a>0;a--){var u=BX.pos(r[a]);if(u["left"]-i<e){l["col"]=a;return l}}}return l}}}}return false},returnToolbarsPositions:function(){return this.arToolbarPositions},AddToolbar:function(e,t,o,i){CACHE_DISPATCHER["pEditorFrame"]=null;e.bDocked=true;var l=null;var s;e.SetDirection(this.bVertical);if(this.bVertical){var n=this.pWnd.rows[0].cells;var a,d;if(o>n.length)o=n.length;if(o>=n.length||i){var p=this.pWnd.rows[0].insertCell(o);p.style.verticalAlign="top";d=p.appendChild(this.pMainObj.pDocument.createElement("TABLE"));d.cellSpacing=0;d.cellPadding=0;d.border=0;d.unselectable="on"}else{d=n[o].childNodes[0];if(d.clientHeight+e.pWnd.clientHeight>this.pMainObj.arConfig["height"]){d=null;return this.AddToolbar(e,t,o+1,i)}}if(t>d.rows.length)t=d.rows.length;a=d.insertRow(t);l=a.insertCell(0);d=null;a=null;p=null;n=null}else{var h=this.pWnd.childNodes;var c;if(t>h.length)t=h.length;if(t>=h.length||i){var b=BX.create("TABLE",{props:{className:"bxed-toolbar-inner",cellSpacing:0,cellPadding:0,unselectable:"on"}});b.insertRow(0);c=t>=h.length?this.pWnd.appendChild(b):this.pWnd.insertBefore(b,h[t])}else{c=h[t];if(c.clientWidth+e.pWnd.clientWidth>this.pMainObj.arConfig["width"])return this.AddToolbar(e,t+1,o,i)}if(o>c.rows[0].cells.length)o=c.rows[0].cells.length;l=c.rows[0].insertCell(o);s=e.pIconsTable.rows[0];s.cells[0].style.display=GetDisplStr(1);s.cells[s.cells.length-1].style.display=GetDisplStr(1);r=null;b=null;c=null;h=null}e.row=t;e.col=o;e.pWnd.style.position="relative";e.pWnd.style.left=null;e.pWnd.style.top=null;e.pTitleRow.style.display="none";e.pWnd=l.appendChild(e.pWnd);e.pWnd.style.position="";e.pToolbarSet=this;e.parentCell=l;l.style.width="10px";this.__ReCalc();l=null},DelToolbar:function(e){CACHE_DISPATCHER["pEditorFrame"]=null;e.parentCell.removeChild(e.pWnd);e.pToolbarSet=null;this.__ReCalc()},__ReCalc:function(){var e,t,o,i,l,s;if(this.bVertical){l=this.pWnd.rows[0].cells;for(t=l.length-1;t>=0;t--){e=l[t].childNodes[0].rows;for(o=e.length-1;o>=0;o--)if(e[o].cells[0].childNodes.length<=0)l[t].childNodes[0].deleteRow(o);if(l[t].childNodes[0].rows.length<=0)this.pWnd.rows[0].deleteCell(t)}for(t=0;t<l.length;t++){e=l[t].childNodes[0].rows;for(o=0;o<e.length;o++){i=e[o].cells[0].childNodes[0].pObj;i.row=o;i.col=t;this.arToolbarPositions[i.name]=[i.row,i.col]}}}else{e=this.pWnd.childNodes;for(t=e.length-1;t>=0;t--){var n=e[t];for(o=n.rows[0].cells.length-1;o>=0;o--){if(n.rows[0].cells[o].childNodes.length<=0)n.rows[0].deleteCell(o)}if(n.rows[0].cells.length<=0)this.pWnd.removeChild(n);else n.rows[0].insertCell(-1)}for(t=0;t<e.length;t++){for(o=0;o<e[t].rows[0].cells.length;o++){s=e[t].rows[0].cells[o].childNodes[0];if(!s||!s.pObj)continue;i=s.pObj;i.row=t;i.col=o;this.arToolbarPositions[i.name]=[i.row,i.col]}}}i=null;n=null;e=null}};function BXToolbar(e,t,o,i,s){ar_BXToolbarS.push(this);this.pMainObj=e;this.className="BXToolbar";this.id=Math.random();this.name=o;this.bVertical=false;this.title=t;this.actTInd=0;this.buttons=[];var n=this;var r=BX.create("TABLE",{props:{className:"bx-toolbar-tbl",unselectable:"on"},style:{width:i!=null?i:"0%",height:s!=null?s:"20px"}});r.pObj=this;r.ondragstart=function(e){return false};this.pTitleRow=r.insertRow(0);var a=BX.adjust(this.pTitleRow.insertCell(0),{props:{className:"bxedtoolbartitle",noWrap:"nowrap",unselectable:"on"}});a.innerHTML='<table class="bxedtoolbartitletext"><tr><td width="99%" nowrap style="padding: 0px 1px 1px 8px;">'+t+'</td><td width="0%">&nbsp;</td><td id="title_x_'+this.id+'" width="1%" style="padding: 0px 3px 0px 3px; cursor: default;"><img src="'+one_gif_src+'" class= "iconkit_c bx-toolbar-x" /></td></table>';a.onmousedown=function(e){n.MouseDown(e);return false};var d=r.insertRow(1).insertCell(0);d.className="bxedtoolbar";d.unselectable="on";var p=BX.create("TABLE",{props:{className:"bxedtoolbaricons",unselectable:"on"}});p.style.height=s!=null?s:"22px";var h=p.insertRow(0);h.style.backgroundImage="url("+image_path+"/toolbarbg.gif)";var c=h.insertCell(0);c.style.width="0%";c.style.cursor="move";c.appendChild(e.CreateElement("DIV",{title:t,className:"iconkit_c"},{backgroundPosition:"-317px -96px",width:"12px",height:"25px"}));c.unselectable="on";c.onmousedown=function(e){n.MouseDown(e);return false};c=h.insertCell(-1);c.unselectable="on";c.style.width="100%";c.style.backgroundImage="url("+image_path+"/toolbarbg.gif)";c.innerHTML=" ";c=h.insertCell(-1);c.unselectable="on";c.style.width="0%";c.appendChild(e.CreateElement("DIV",{title:t,className:"iconkit_c"},{backgroundPosition:"-334px -96px",width:"5px",height:"25px"}));c.onmousedown=function(e){n.MouseDown(e);return false};this.pIconsTable=d.appendChild(p);this.pWnd=this.pMainObj.pWnd.appendChild(r);var b=e.pDocument.getElementById("title_x_"+this.id);b.onmousedown=function(e){n.Close(e)};b=null;BXToolbar.prototype.AddButton=function(e,t){var o=this.pIconsTable.rows[0];var i=o.cells.length-3;if(!t||t>i)t=i;var l=o.insertCell(t+1);l.unselectable="on";l.style.backgroundImage="url("+image_path+"/toolbarbg.gif)";l.style.width="0%";l.appendChild(e.pWnd);l.pObj=e;l=null;o=null};BXToolbar.prototype.SetDirection=function(o){if(this.bVertical==o)return;var i=this;this.bVertical=o;var s,n,r,a=Array();if(o){r=this.pIconsTable.rows[0].cells;n=0;while(r.length>3)a[n++]=this.pIconsTable.rows[0].removeChild(r[1]);this.pIconsTable.deleteRow(0);var d=this.pIconsTable.insertRow(0).insertCell(0);d.appendChild(e.CreateElement("DIV",{title:t,className:"iconkit_c"},{backgroundPosition:"-291px -100px",width:"25px",height:"12px"}));d.style.width="0%";d.onmousedown=function(e){i.MouseDown(e);return false};d.style.height="0%";d.style.cursor="move";for(n=0,l=a.length;n<l;n++){var p=this.pIconsTable.insertRow(n+1);d=p.appendChild(a[n]);d.style.backgroundImage="url("+image_path+"/toolbarbg_vert.gif)";if(a[n].pObj.OnToolbarChangeDirection)a[n].pObj.OnToolbarChangeDirection(o)}d=this.pIconsTable.insertRow(-1).insertCell(0).appendChild(e.CreateElement("IMG",{src:one_gif_src,title:t,className:"iconkit_c"},{backgroundPosition:"-291px -113px",width:"25px",height:"5px"}));d=null;p=null}else{r=this.pIconsTable.rows;for(n=1;n<r.length-1;n++)a[n-1]=r[n].removeChild(r[n].cells[0]);while(this.pIconsTable.rows.length>0)this.pIconsTable.deleteRow(0);var h=this.pIconsTable.insertRow(0);var c=h.insertCell(0);c.appendChild(e.CreateElement("DIV",{title:t,className:"iconkit_c"},{backgroundPosition:"-317px -96px",width:"12px",height:"25px"}));c.style.width="0%";c.style.height="0%";c.style.cursor="move";c.onmousedown=function(e){i.MouseDown(e);return false};for(n=0;n<a.length;n++){c=h.appendChild(a[n]);c.style.width="0%";c.style.backgroundImage="url("+image_path+"/toolbarbg.gif)";if(c.pObj.OnToolbarChangeDirection)c.pObj.OnToolbarChangeDirection(o)}var b=h.cells.length;c=h.insertCell(b);c.innerHTML=" ";c.style.width="100%";h.insertCell(-1).appendChild(e.CreateElement("DIV",{title:t,className:"iconkit_c"},{backgroundPosition:"-334px -96px",width:"5px",height:"25px"}));r=null;h=null;c=null}}}BXToolbar.prototype={MouseDown:function(e){e=getRealMousePos(e,this.pMainObj);var t=BX.pos(this.pWnd);this.pMainObj.bDragging=true;this.bDragging=true;this.pMainObj.iLeftDragOffset=e.realX-t["left"];this.pMainObj.iTopDragOffset=e.realY-t["top"];pBXEventDispatcher.SetCursor("move");this.pWnd.oldBorder=this.pWnd.style.border;if(BX.ZIndexManager.getComponent(this.pWnd)){BX.ZIndexManager.bringToFront(this.pWnd)}var o=this;var i=function(e){o.MouseMove(getRealMousePos(e,o.pMainObj))};var l=function(e){o.MouseMove(getRealMousePos(e,o.pMainObj,true))};var s=function(e){removeAdvEvent(document,"mousemove",i,true);removeAdvEvent(document,"mouseup",s,true);removeAdvEvent(o.pMainObj.pEditorDocument,"mousemove",l,true);removeAdvEvent(o.pMainObj.pEditorDocument,"mouseup",s,true);if(BX.browser.IsIE()){removeAdvEvent(o.pMainObj.pEditorDocument,"selectstart",n,true);removeAdvEvent(document,"selectstart",n,true)}if(o.pMainObj.bDragging&&o.bDragging){o.pMainObj.bDragging=false;o.bDragging=false;o.pWnd.style.border=o.pWnd.oldBorder;pBXEventDispatcher.SetCursor("auto");o.SaveConfiguration()}o.pMainObj.arTaskbarSet[2]._SetTmpClass(true);o.pMainObj.arTaskbarSet[2].Resize();o.pMainObj.arTaskbarSet[3].Resize()};var n=function(e){return false};addAdvEvent(document,"mousemove",i,true);addAdvEvent(this.pMainObj.pEditorDocument,"mousemove",l,true);addAdvEvent(document,"mouseup",s,true);addAdvEvent(this.pMainObj.pEditorDocument,"mouseup",s,true);if(BX.browser.IsIE()){addAdvEvent(this.pMainObj.pEditorDocument,"selectstart",n,true);addAdvEvent(document,"selectstart",n,true)}if(e.stopPropagandation)e.stopPropagandation();else e.cancelBubble=true},UnDock:function(){if(this.pToolbarSet)this.pToolbarSet.DelToolbar(this);this.pWnd.style.position="absolute";document.body.appendChild(this.pWnd);BX.ZIndexManager.register(this.pWnd);var e=this.pIconsTable.rows[0];this.pTitleRow.style.display=GetDisplStr(1);this.SetDirection(false);this.bDocked=false},Close:function(){if(this.pToolbarSet)this.pToolbarSet.DelToolbar(this);this.pWnd.style.display=GetDisplStr(0);this.SaveConfiguration()},SaveConfiguration:function(){var e=copyObj(SETTINGS[this.pMainObj.name].arToolbarSettings);if(this.bDocked)this.ReCalcPositions();var t=SETTINGS[this.pMainObj.name].arToolbarSettings;t[this.name].show=!(this.pWnd.style.display=="none"&&this.name!="standart");if(!this.bDocked){t[this.name].docked=false;t[this.name].position={x:this.pWnd.style.left,y:this.pWnd.style.top}}if(compareObj(e,t))return;this.pMainObj.SaveConfig("toolbars",{tlbrset:t})},ReCalcPositions:function(){var e=SETTINGS[this.pMainObj.name].arToolbarSettings;var t=this.pMainObj.GetToolbarSet();var o=t[this.actTInd].returnToolbarsPositions();e[this.name].docked=true;e[this.name].position=[];for(var i in o)if(e[i]&&e[i].docked)e[i].position=[this.actTInd,o[i][0],o[i][1]]},SetPosition:function(e,t){if(this.bDocked)this.UnDock();this.pWnd.style.top=(t||0)+"px";this.pWnd.style.left=(e||0)+"px"},MouseMove:function(e){if(this.pMainObj.bDragging&&this.bDragging){var t,o,i=false,l=false,s,n=this.pMainObj.GetToolbarSet(),r,a=n.length;for(r=0;r<a;r++){if(s=n[r].HitTest(e.realX,e.realY,r)){i=true;l=n[r];this.actTInd=r;break}}t=e.realX-this.pMainObj.iLeftDragOffset;o=e.realY-this.pMainObj.iTopDragOffset;if(isNaN(t)||t<0)t=0;if(isNaN(o)||o<0)o=0;t+="px";o+="px";if(this.bDocked&&!i){this.UnDock();this.pWnd.style.left=t;this.pWnd.style.top=o}else if(!this.bDocked&&i&&l){if(this.pToolbarSet)this.pToolbarSet.DelToolbar(this);l.AddToolbar(this,s["row"],s["col"],s["addrow"])}else if(!this.bDocked&&!i){this.pWnd.style.left=t;this.pWnd.style.top=o}else if(s["addrow"]||this.row!=s["row"]||this.col!=s["col"]){if(this.pToolbarSet)this.pToolbarSet.DelToolbar(this);l.AddToolbar(this,s["row"],s["col"],s["addrow"])}this.bDocked=i}}};function BXRefreshToolbars(e){var t=SETTINGS[e.name].arToolbarSettings,o,i,l;for(i in ar_BXToolbarS){l=ar_BXToolbarS[i];o=l.name;if(l.pMainObj.name!=e.name)continue;if(!t||!t[o])continue;if(t[o].show&&l.pWnd.style.display=="none"){if(t[o].docked)e.arToolbarSet[t[o].position[0]].AddToolbar(l,t[o].position[1],t[o].position[2]);l.pWnd.style.display=GetDisplStr(1)}else if(!t[o].show&&l.pWnd.style.display!="none"){if(l.pToolbarSet)l.pToolbarSet.DelToolbar(l);l.pWnd.style.display=GetDisplStr(0)}}}
//# sourceMappingURL=bars_ex.map.js